/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Object;

import FrameWork.Rectangle;
import GamePlay.Global;

/**
 *
 * @author ThanhTri
 */
public class MyObject {
    public int       m_CurFrame;
    public float     m_SaveTimeAni, m_TimeAni;
    public float     m_TimeUpdate;
    public float     m_X, m_Y;
    public int       m_Width, m_Height;
    public int       m_ID;
    public int       m_Status;
    public MyObject (MyObject _Object){
        m_X             = _Object.m_X;
        m_Y             = _Object.m_Y;
        m_ID            = _Object.m_ID;
        m_Width         = _Object.m_Width;
        m_Height        = _Object.m_Height;
        m_TimeAni       = _Object.m_TimeAni;
        m_Status        = _Object.m_Status;
        m_SaveTimeAni   = _Object.m_SaveTimeAni;
        m_CurFrame      = _Object.m_CurFrame;
        m_TimeUpdate    = 0;         
    }
     public MyObject(int _X,int _Y,
            int _Width, int _Height,
            int _ID){
        m_X             = _X;
        m_Y             = _Y;
        m_Height        = _Height;
        m_Width         = _Width;        
        m_SaveTimeAni   = 0;
        m_CurFrame      = 0;
        m_TimeUpdate    = 0;        
        m_ID            = _ID;
    }
     public MyObject(int _X,int _Y,
            int _Width, int _Height,
            int _ID,int _Eggs){
        m_X             = _X;
        m_Y             = _Y;
        m_Height        = _Height;
        m_Width         = _Width;        
        m_SaveTimeAni   = 0;
        m_CurFrame      = 0;
        m_TimeUpdate    = 0;        
        m_ID            = _ID;
        m_CurFrame      = _Eggs;
        m_Status        = Global.STT_ACTIVE;
    }
     public void Update(float _Time){
        if(m_Status==Global.STT_ACTIVE){
             m_SaveTimeAni+= _Time;
            if(m_SaveTimeAni>=1){
               m_SaveTimeAni-=1;
               m_CurFrame=(m_CurFrame+1)%3;
           }
        }else{
           m_TimeUpdate+= _Time;
           if (m_TimeUpdate>=0.3f) {
               m_Status = Global.STT_DIE;
           }
       }           
    }
     public void UpdateEggs (float _Time)
     {
         if(m_Status!=Global.STT_ACTIVE){
            m_TimeUpdate+= _Time;
           if (m_TimeUpdate>=0.3f) {
               m_Status = Global.STT_DIE;
           }
        }       
     }
     public Rectangle Rect (){
         return new Rectangle((int)m_X, (int)m_Y, m_Width, m_Height);
     }
}
